package it.antonio.ilpizze.ioc;

public abstract class TransformationFactory<T> {
	public abstract Transformation<T> transformation(Object key, Class<? extends T> type);
	
	
	public static <T> TransformationFactory<T> fromTransformation(final Transformation<T> cont) {
		return new TransformationFactory<T>() {
			
			@Override
			public Transformation<T> transformation(Object key, Class<? extends T> type) {
				return cont;
			}
		};
	}
	
	public static <T> TransformationFactory<T> identity(){
		return new TransformationFactory<T>() {

			@Override
			public Transformation<T> transformation(Object key, Class<? extends T> type) {
				return new Transformation<T>() {

					@Override
					public T transform(T instance) {
						return instance;
					}
				};
			}
			
		};
		
	}

	
	
}
